
  import Vue from 'vue';
  import Router from 'vue-router';
  
  Vue.use(Router)
  
  //路由组
  import admin from './router_group/admin';
    import admin_manager from './router_group/admin_manager';
    import jd_sort_m from './router_group/jd_sort_m';
    import jd_m from './router_group/jd_m';
    import cur_goods_m from './router_group/cur_goods_m';
    import store_m from './router_group/store_m';
    import goods_verify_m from './router_group/goods_verify_m';
    import banner_manager from './router_group/banner_manager';
    import charge_m from './router_group/charge_m';
    import financial_m from './router_group/financial_m';
    import member_m from './router_group/member_m';
    import agent_m from './router_group/agent_m';
    import node_m from './router_group/node_m';
    import team_m from './router_group/team_m';
    import ping_tuan_m from './router_group/ping_tuan_m';
    import order_m from './router_group/order_m';
    import good_classify_m from './router_group/good_classify_m';
    import news_m from './router_group/news_m';
    import abnormal_m from './router_group/abnormal_m';
    import version_m from './router_group/version_m';
    
  

  // const _404 = () => import('@/pages/_404'); //404
  // const admin_manager_table = () => import('@/pages/admin_manager/table'); //初始页面} 
  
  const _404 = () => import ('@/pages/_404') ; //404
  const admin_manager_table = () =>  import('@/pages/admin_manager/table') ; //初始页面} 

  // import _404 from '@/pages/_404'; //404
  // import admin_manager_table from '@/pages/admin_manager/table'; //初始页面
  
  const router = new Router({
    // mode: 'history',
    // base: '/merchants/',  //添加默认路由
    routes: [
      ...admin,
    ...admin_manager,
    ...jd_sort_m,
    ...jd_m,
    ...cur_goods_m,
    ...store_m,
    ...goods_verify_m,
    ...banner_manager,
    ...charge_m,
    ...financial_m,
    ...member_m,
    ...agent_m,
    ...node_m,
    ...team_m,
    ...ping_tuan_m,
    ...order_m,
    ...good_classify_m,
    ...news_m,
    ...abnormal_m,
    ...version_m,
    
  
      {
        path: '/',
        name: '',
        component: admin_manager_table  //修改
      },
      {
        path: '/index',
        name: '',
        component: admin_manager_table  //修改
      },
      {
        path: '*',
        name: '',
        component: _404
      },
  
    ]
  })
  
    export default router;
    
  
    //登录路由守卫
    router.beforeEach((to, from, next) => {
      const sessionId = sessionStorage.getItem('sessionId');
    
      if (Object.is(to.path, '/admin_login') || Object.is(to.path, '/admin_register')) {
        next();
        return
      }
    
      if (sessionId) {
        next();
      } else {
        router.push({ path: '/admin_login' })
      }
    
      // 参考 https://www.cnblogs.com/elfpower/p/9230528.html
      // https://blog.csdn.net/dianchou8532/article/details/101994999
    });
    
  